package tables;

import java.util.Date;

public class Affectation implements Tables_SUPER {

	private int id_personne;
	private int numBadge;
	private java.sql.Date date_affectation;
	private java.sql.Date date_fin_affectation;
	
	public Affectation(int id_personne, int numBadge, java.sql.Date date_affectation, java.sql.Date date_fin_affectation) {
		this.id_personne = id_personne;
		this.numBadge = numBadge;
		this.date_fin_affectation = date_fin_affectation;
	}
	@Override
	public String insert() {
		java.util.Date today = new Date();
		java.sql.Date dateJour = new java.sql.Date(today.getTime());
		String cmd = null;
		
		if(date_fin_affectation == null){
			cmd = "INSERT INTO AFFECTATION VALUES("+id_personne+","+numBadge+",TO_date('"+dateJour+"','YYYY-MM-DD'),null)";
		}else{
			cmd = "INSERT INTO AFFECTATION VALUES("+id_personne+","+numBadge+",TO_date('"+dateJour+"','YYYY-MM-DD'),TO_date('"+date_fin_affectation+"','YYYY-MM-DD'))";
		}
		return cmd;
	}
	@Override
	public String update() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public String delete() {
		// TODO Auto-generated method stub
		return null;
	}

	//getter & setter	
	public int getId_personne() {
		return id_personne;
	}

	public void setId_personne(int id_personne) {
		this.id_personne = id_personne;
	}

	public int getNumBadge() {
		return numBadge;
	}

	public void setNumBadge(int numBadge) {
		this.numBadge = numBadge;
	}

	public java.sql.Date getDate_affectation() {
		return date_affectation;
	}

	public void setDate_affectation(java.sql.Date date_affectation) {
		this.date_affectation = date_affectation;
	}

	public java.sql.Date getDate_fin_affectation() {
		return date_fin_affectation;
	}

	public void setDate_fin_affectation(java.sql.Date date_fin_affectation) {
		this.date_fin_affectation = date_fin_affectation;
	}

}
